<script type="text/javascript">

function pilihProcess(id,code,name){


		$('#nama_process').val(name);
		$('#id_process').val(id);
		
      	$("#dialogProcess").dialog("close");
		 
     };

</script>


<div class="form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'item-status-form',
	'enableAjaxValidation'=>false,
        'method'=>'post',
	'type'=>'horizontal',
	'htmlOptions'=>array(
		'enctype'=>'multipart/form-data'
	)
)); ?>
     	<fieldset>
		<legend>
			<p class="note">Fields with <span class="required">*</span> are required.</p>
		</legend>

	<?php echo $form->errorSummary($model,'Opps!!!', null,array('class'=>'alert alert-error span12')); ?>
        		
   <div class="control-group">		
			<div class="span4">


	<div class="control-group ">
				<label class="control-label required">Process</label>
				<div class="controls">

				
				<?php
				if($model->isNewRecord){
				?>
				<input type="text" name="nama_process" id="nama_process" class="span4" readonly="readonly">
				<?php
				}
				else{
				?>
				<input type="text" name="nama_process" id="nama_process" class="span4" readonly="readonly" value="<?php echo ItemProcess::model()->findByPk($model->id_process)->name; ?>">
				<?php
				}
				?>

				<?php echo $form->hiddenField($model,'id_process',array('class'=>'span4','id'=>'id_process')); ?>

				<a class="btn btn-secondary-small" onclick="$(&quot;#dialogProcess&quot;).dialog(&quot;open&quot;); return false;" href="#">Search</a>

    </div></div>


    <?php echo $form->textFieldRow($model,'code',array('class'=>'span5','maxlength'=>5)); ?>

	<?php echo $form->textFieldRow($model,'name',array('class'=>'span5','maxlength'=>50)); ?>

	<?php echo $form->textAreaRow($model,'description',array('class'=>'span5','maxlength'=>50)); ?>

	


                        </div>   
  </div>

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
                        'icon'=>'ok white',  
			'label'=>$model->isNewRecord ? 'Create' : 'Save',
		)); ?>
              <?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'reset',
                        'icon'=>'remove',  
			'label'=>'Reset',
		)); ?>
	</div>
</fieldset>

<?php $this->endWidget(); ?>

</div>


<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id' => 'dialogProcess',
     'theme'=>'sunny',
    'themeUrl'=>Yii::app()->request->baseUrl.'/css/themes',
    'options' => array(
        'title' => 'Data Process',
        'width' => 600,
        'height' => 600,
        'autoOpen' => false,
    ),
));
?>

<?php 
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('categories-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
$this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'categories-grid',
	'dataProvider'=>$modelProcess->search(),
	'filter'=>$modelProcess,
	'columns'=>array(
		'code',
		'name',
		array(
					'value'=>'CHtml::submitButton("Select",array("id"=>$data->id,"code"=>$data->code,"name"=>$data->name,"onClick"=>"pilihProcess($(this).attr(\'id\'),$(this).attr(\'code\'),$(this).attr(\'name\'))"))',
					'type'=>'raw',
				),
		
	),
)); ?>

<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
